<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__STATIC__/css/layui.css">
    <link rel="stylesheet" href="__STATIC__/css/login.css">
    <link rel="icon" href="/favicon.ico">
    <title>管理后台</title>
</head>
<body class="login-wrap">
    <div class="login-container">
        <form class="login-form">
           <h3 class="text-center">登录</h3>
            <div class="input-group">
                <input type="text" id="admin_username" class="input-field" placeholder="管理员账号">
              <!--   <label for="username" class="input-label">
                    <span class="label-title">用户名</span>
                </label> -->
            </div>
            <div class="input-group">
                <input type="password" id="admin_password" class="input-field" placeholder="管理员账号">
               <!--  <label for="password" class="input-label">
                    <span class="label-title">密码</span>
                </label> -->
            </div>
            <button type="button" class="login-button" onclick="dologin();">登录<i class="ai ai-enter"></i></button>
        </form>
    </div>
</body>
<script src="__STATIC__/layui.js"></script>
<script src="__STATIC__/jquery.min.js"></script>
<script src="__STATIC__/login.js" data-main="login"></script>
<script type="text/javascript">
  // 登陆
   layui.use('upload', function(){
    var $ = layui.jquery
        ,upload = layui.upload;
});

  function dologin(){
      var admin_username = $("#admin_username").val();
      if(admin_username == ""){
          layer.msg("请输入账号",{time:1000});
      }else{
          var admin_password = $("#admin_password").val();
          if(admin_password == ""){
              layer.msg("请输入密码",{time:1000});
          }else{
              $.ajax({
                  url: "{:Url('Login/login')}",
                  type: "POST",
                  data: {"admin_username":admin_username,"admin_password":admin_password},
                  dataType: "text",
                  success:function(res){
                      // console.log(res);
                      if(res == "1"){
                          // console.log(res);
                          layer.msg("登陆成功",{time:1000});
                          window.location.href = "{:Url('Index/index')}";
                      }else{
                          layer.msg("登陆账号或密码错误",{time:1000});
                      }
                  }
              })
          }
      }
  }</script>
</html>